/**
 * 1
 *  
 * @Author : Ruoyu Wang
 * @DateTime : 24-9-11 下午7:49
 */

#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <stack>

using namespace std;

int main() {
    string s;
    getline(cin, s);
    stringstream ss(s);
    string tmp;
    stack<int> nums;
    while (getline(ss, tmp, ',')) {
        if (tmp[0] >= '0' && tmp[0] <= '9') {
            nums.push(stoi(tmp));
        } else {
            int b = nums.top();
            nums.pop();
            int a = nums.top();
            nums.pop();
            if (tmp == "+") {
                nums.push(a + b);
            } else if (tmp == "-") {
                nums.push(a - b);
            } else if (tmp == "*") {
                nums.push(a * b);
            } else if (tmp == "/") {
                nums.push(a / b);
            }
        }
    }
    cout << nums.top();
    return 0;
}